<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" placeholder="请输入一个数字">
    <input type="button" value="查看">
</body>
<script>
    let inpArr = document.querySelectorAll('input')
    inpArr[1].onclick = function(){
        let num = inpArr[0].value
        for(let i = 0;i<num;i++){
            if(i==1) continue
            if(num % i == 0){
                return alert(num+'不是素数')
            }
        }
        alert(num+'是素数')
    }
</script>
</html>